//
//  BYConfirmOrderAddressCell.m
//  OCDemo
//
//  Created by zhumuzhi on 2022/2/16.
//

#import "BYConfirmOrderAddressCell.h"

@interface BYConfirmOrderAddressCell ()

// 联系人
@property (nonatomic, strong) UILabel       *consignee;
// 手机
@property (nonatomic, strong) UILabel       *phone;
// 地址
@property (nonatomic, strong) UILabel       *address;
// 底部线条
@property (nonatomic, strong) UIImageView   *line;
// 编辑按钮
@property (nonatomic, strong) UIButton      *edit;

@end

@implementation BYConfirmOrderAddressCell

#pragma mark - Event
- (void)editEvent {
    NSLog(@"编辑事件");
}

#pragma mark - SetData



#pragma mark - CellHeight
+(CGFloat)cellHeight {
    return kAutoWithSize(130);
}

#pragma mark - init

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self.contentView addSubview:self.consignee];
        [self.contentView addSubview:self.phone];
        [self.contentView addSubview:self.address];
        [self.contentView addSubview:self.edit];
        [self.contentView addSubview:self.line];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
        
    [self.consignee mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(kAutoWithSize(10));
        make.left.equalTo(self.contentView).offset(kAutoWithSize(10));
    }];
    
    [self.phone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-kAutoWithSize(10));
        make.top.equalTo(self.consignee);
    }];
    
    [self.address mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.consignee.mas_bottom).offset(kAutoWithSize(10));
        make.left.equalTo(self.consignee);
        make.right.equalTo(self.contentView).offset(-kAutoWithSize(10));
    }];
    
    [self.edit mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-kAutoWithSize(10));
        make.top.equalTo(self.address.mas_bottom).offset(kAutoWithSize(10));
        make.width.mas_equalTo(kAutoWithSize(60));
    }];
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView);
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(kAutoWithSize(2));
    }];
}


#pragma mark - LazyGet

- (UILabel *)consignee {
    if(!_consignee) {
        _consignee = [[UILabel alloc] init];
        _consignee.text = @"罗克";
        
    }
    return _consignee;
}

- (UILabel *)phone {
    if(!_phone) {
        _phone = [[UILabel alloc] init];
        _phone.textAlignment = NSTextAlignmentRight;
        _phone.text = @"15812348888";
    }
    return _phone;
}

- (UILabel *)address {
    if(!_address) {
        _address = [[UILabel alloc] init];
        _address.numberOfLines = 0;
        _address.text = @"北京市海淀区西土城路10号枫丹丽舍1单302";
    }
    return _address;
}

-(UIButton *)edit {
    if (!_edit) {
        _edit = [[UIButton alloc] init];
        [_edit setTitle:@"编辑" forState:UIControlStateNormal];
        [_edit setBackgroundColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        [_edit addTarget:self action:@selector(editEvent) forControlEvents:UIControlStateNormal];
    }
    return _edit;
}

- (UIImageView *)line {
    if(!_line) {
        _line = [[UIImageView alloc] init];
        _line.image = [UIImage imageNamed:@"address_line"];
    }
    return _line;
}




@end
